
from Ship import Ship
# CMDID
from Body.Command import CMD_UP,CMD_DOWN,CMD_LEFT,CMD_RIGHT,CMD_BTN0,CMD_BTN1
#
from Body.Define import SCREEN_X, SCREEN_Y
from pandac.PandaModules import Point2
import random

class Player:
    def __init__(self, MyInfo):
        self.MyInfo = MyInfo

        posX = random.randint(-SCREEN_X*100, SCREEN_X*100)/100.0
        posY = random.randint(-SCREEN_Y*100, SCREEN_Y*100)/100.0
        print "Random ship pos= ",posX,posY
        self.Ship = Ship(pos = Point2(posX,posY)) #
        self.ShipCmdList = [CMD_UP,CMD_DOWN,CMD_LEFT,CMD_RIGHT]

    def CmdHandle(self, param):
        cmd, value = param[0], param[1]
        if cmd in self.ShipCmdList:
            self.Ship.CmdInput(cmd, value)

    def LogicUpdate(self, periods):
        self.Ship.Update(periods)